package leecode.数组和字符串.杨辉三角;

import java.util.ArrayList;

public class YhTriangle {
    public static void main(String[] args) {
        soulution soulution = new soulution();
        ArrayList<ArrayList<Integer>> arrayLists = soulution.YhTriangle(5);
        System.out.println(arrayLists);

    }

    static class soulution{
        public ArrayList<ArrayList<Integer>>  YhTriangle(int Line){
            ArrayList<ArrayList<Integer>> triangle = new ArrayList<>();
            for (int i = 0; i < Line; ++i) {
                ArrayList<Integer> temp = new ArrayList<>();
                for (int j = 0; j <= i; ++j) {
                    if (j==0 || j==i){
                        temp.add(1);
                    }else {
                        temp.add(triangle.get(i-1).get(j-1)+triangle.get(i-1).get(j));
                    }

                }
                triangle.add(temp);

            }

            return triangle;
        }
    }
}
